package com.FrameWork.Common;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.SFA.R;

public class BuilderView extends LinearLayout {
	private TextView txtTitle;
	private LinearLayout layoutBottom; 

	
	public BuilderView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		Init(context);
	}
	

	public BuilderView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
		Init(context);
		TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SortView);
		setTitle(array.getString(R.styleable.SortView_ButtonTitle));
		array.recycle();
		array=null;
	}


	public void Init(Context context) {
		setGravity(Gravity.CENTER);
	
		this.setClickable(true);
		this.setFocusable(true);
		LayoutInflater inflater = LayoutInflater.from(context);
		inflater.inflate(R.layout.builderview, this);
		txtTitle = (TextView) this.findViewById(R.id.txtTitle);
		layoutBottom = (LinearLayout) this.findViewById(R.id.layoutBottom);
		setWillNotDraw(false);
	}

	



	public void setTitle(String title)
	{
		if(txtTitle != null)
			txtTitle.setText(title);
	}
	
	public void setTitle(int resID)
	{
		if(txtTitle != null)
			txtTitle.setText(resID);
	}
	


	@Override
	public void setSelected(boolean selected) {
		// TODO Auto-generated method stub
		if(selected)
		{
			layoutBottom.setVisibility(View.VISIBLE);
			txtTitle.setTextColor(getResources().getColor(R.color.htinns));
		}
		else
		{
			layoutBottom.setVisibility(View.INVISIBLE);
			txtTitle.setTextColor(getResources().getColor(R.color.gray));
		}
		
		//this.refreshDrawableState();
	}


}
